#ifndef _SM3_H_
#define _SM3_H_

#ifdef __cplusplus
extern "C" 
{
#endif

#define	 SM3_DIGEST_LENGTH		32

/*SM3 context.*/
typedef struct{
    unsigned int stateIV[8];
    unsigned int count[2];
    unsigned int T[64];
    unsigned char buffer[64];
}SM3_CONTEXT;


/**
 * @brief           SM3 digest initialize
 *
 * @param   pCtx    output context struct
 */
void SM3_Init(SM3_CONTEXT *pCtx);

/**
 * @brief               SM3 digest update
 *
 * @param   pCtx        input context struct
 * @param   pData       input block
 * @param   lDataLen    length of input block
 */
void SM3_Update(SM3_CONTEXT *pCtx, unsigned char *pData, unsigned int lDataLen);

/**
 * @brief               SM3 digest finalize
 *
 * @param   pCtx        input context struct
 * @param   result[32]  output message digest
 */
void SM3_Final(SM3_CONTEXT *pCtx,unsigned char result[32]);

/**
 * @brief               SM3 digest
 *
 * @param   data        input block
 * @param   len         length of data
 * @param   result[32]  output message digest
 */
void sm3(unsigned char *data, unsigned int len, unsigned char result[32]);

#ifdef __cplusplus
}  /* end extern "C" */
#endif


#endif                         /*_SM3_H_*/
